package com.ljy.my_study.java.classloader;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

/**
 * @author lijunying
 * @date 2021/2/5 16:06
 */
public class TestMain {

    public static void main(String[] args) throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InstantiationException, InvocationTargetException {
        MyClassLoader myClassLoader=new MyClassLoader();
        Thread.currentThread().setContextClassLoader(myClassLoader);
        Class<Student> student= (Class<Student>) myClassLoader.loadClass("com.ljy.my_study.java.classloader.Student");

        Class<Student> studentClass= (Class<Student>) Class.forName("com.ljy.my_study.java.classloader.Student");
        System.out.println(studentClass);

        Class<Student> studentClass1= Student.class;
        System.out.println(studentClass1);

        Student student1=new Student();
        Constructor<Student> constructor= Student.class.getConstructor();
        Student student2=constructor.newInstance();
        Student student3=Student.class.newInstance();
    }
}
